#pragma once

#include <iostream>
#include <string>

class Task
{
public:
    Task(int left = 0, int right = 0, char op = '0')
        : left_(left)
        , right_(right)
        , op_(op)
    {}

    int cal()
    {
        int src = 0;
        switch (op_)
        {
        case '+':
            src = left_ + right_;
            break;
        case '-':
            src = left_ - right_;
            break;
        case '*':
            src = left_ * right_;
            break;
        case '/':
            if (right_ == 0) 
            {
                std::cout << "div zero -> abort" << std::endl;
                src = -1;
            }
            else 
            {
                src = left_ / right_;
            }
            break;
        case '%':
            src = left_ % right_;
            break;
        default:
            std::cout << "op = " << op_ << std::endl;
            std::cout  << "非法操作" << std::endl;
            break;
        }
        return src;
    }

    // 仿函数
    int operator()()
    {
        return cal();
    }

    int get(int* left, int* right, char* op)
    {
        *left = left_;
        *right = right_;
        *op = op_;
    }

private:
    int left_;
    int right_;
    char op_;
};